<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Backend_Form_Product_Create
 *
 * @author Eugene
 */
class Backend_Form_Product_Create extends Zend_Form
{

	/**
	 *
	 * @return void
	 */
	public function init()
	{
		$this->setAction($this->getView()->url());
		$this->setMethod(Zend_Form::METHOD_POST);

		$this->addElement('text', 'name', array(
			'label' => 'Name',
			'required' => true,
			'filters' => array(
				'StringTrim',
				'StripTags'
			),
			'validators' => array(
				array('Alnum'),
				array('StringLength', false, array(4, 255)),
			),
		));

		$this->addElement('select', 'brandId', array(
			'label' => 'Brand',
			'validators' => array(
				array('Digits', true),
				array('Db_RecordExists', false, array(
						'table' => 'brand',
						'field' => 'id'
				))
			),
		));

		$this->addElement('multiselect', 'categories', array(
			'label' => 'Categories',
			'validators' => array(
				array('Digits', true),
				array('Db_RecordExists', false, array(
						'table' => 'category',
						'field' => 'id'
				))
			),
		));

		$this->addElement('textarea', 'description', array(
			'label' => 'Description',
			'required' => true,
			'filters' => array('StringTrim'),
			'validators' => array(
			),
		));

		$this->addElement('checkbox', 'enabled', array(
			'label' => 'Enabled'
		));

		$this->addElement('submit', 'create', array(
			'ignore' => true,
			'label' => 'Create'
		));
	}

}